ActionController::Routing::Routes.draw do |map|
  #map.resources :notes

  # The priority is based upon order of creation: first created -> highest priority.
  
  # Sample of regular route:
  # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # You can have the root of your site routed by hooking up '' 
  # -- just remember to delete public/index.html.
  # map.connect '', :controller => "welcome"
  map.login '/login', :controller => 'sessions', :action => 'new'
  map.logout '/logout', :controller => 'sessions', :action => 'destroy'
  map.connect '', :controller => 'customers', :action => 'index'
  map.connect '/admin', :controller => "admin/users", :action => 'index'


  map.resources :sessions
  map.resources :customers, :collection => {:search => :get}, 
    :has_many => [
    :contacts,
    :addresses,
    :conversations,
    :attachments,
    :quotes,
    :quote_requests,
    :notes
  ]
  map.resources :contacts, :collection => {:destroy_selected => :delete, :search => :get}
  map.resources :addresses, :member => {:print => :get}, :collection => {:destroy_selected => :delete}
  map.resources :attachments, :collection => {:destroy_selected => :delete}
  map.resources :conversations, :collection => {:destroy_selected => :delete},
    :has_one => [
    :customer,
    :contact
  ]
  map.resources :documents, :collection => {:destroy_selected => :delete}
  map.resources :employees, :collection => {:destroy_selected => :delete}
  map.resources :notes, :collection => {:destroy_selected => :delete}
  map.resources :quote_requests, :collection => {:destroy_selected => :delete}
  map.resources :quotes, :collection => {:destroy_selected => :delete}
  map.resources :rights, :collection => {:destroy_selected => :delete}
  map.resources :roles, :collection => {:destroy_selected => :delete}
  map.resources :teams, :collection => {:destroy_selected => :delete},
    :has_many => [:employees]
  map.resources :users, :collection => {:destroy_selected => :delete}
  map.namespace :admin do |admin|
    admin.resources :tags
    admin.resources :users
    admin.resources :roles
    admin.resources :rights
  end


  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:id.:format'
  map.connect ':controller/:action/:id'
  
end
